package cn.wolfcode.luowowo.search.query;

import cn.wolfcode.luowowo.common.query.QueryObject;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

@Getter
@Setter

public class StrategySearchQuery extends QueryObject {

    public static final int CONDITION_THEME = 2; //主题条件
    public static final int CONDITION_CHINA = 1; //国内条件
    public static final int CONDITION_ABROAD = 0; //海外条件

    public Integer type = -1;//攻略统计数据类型  -1默认全部选中
    public Long typeValue = -1L;//攻略统计数据类型的维度id
    private String orderBy = "viewnum";


    public Integer getType() {
        if (this.type == null || type.equals("")) {
            this.type = -1;

        }
        return type;
    }

    public Long getTypeValue() {
        if (this.typeValue == null || typeValue.equals("")) {
            this.typeValue = -1L;

        }
        return typeValue;
    }

    //分页对象
    public Pageable getPageable() {
        //参数1:当前页 -1
        //参数2:每页显示条数
        //参数3:排序对象
        return PageRequest.of(super.getCurrentPage() - 1, super.getPageSize(),
                Sort.by(Sort.Direction.DESC, orderBy));
    }


}
